import api from './api';

// 匹配相关API
export const matchAPI = {
  // 获取推荐的匹配用户
  getRecommendations: async () => {
    try {
      return await api.get('/match/recommendations');
    } catch (error) {
      console.error('获取推荐用户失败', error);
      throw error;
    }
  },

  // 喜欢或不喜欢用户
  createMatch: async (targetUserId: number, liked: boolean) => {
    try {
      return await api.post('/match', { targetUserId, liked });
    } catch (error) {
      console.error('创建匹配失败', error);
      throw error;
    }
  },

  // 获取匹配列表
  getMatches: async () => {
    try {
      return await api.get('/match/list');
    } catch (error) {
      console.error('获取匹配列表失败', error);
      throw error;
    }
  },

  // 获取匹配偏好
  getPreference: async () => {
    try {
      return await api.get('/match/preference');
    } catch (error) {
      console.error('获取匹配偏好失败', error);
      throw error;
    }
  },

  // 更新匹配偏好
  updatePreference: async (preference) => {
    try {
      return await api.post('/match/preference', preference);
    } catch (error) {
      console.error('更新匹配偏好失败', error);
      throw error;
    }
  },
};